package com.nashuju.web.controller.sys;

import java.util.ArrayList;
import java.util.List;

import org.durcframework.core.DefaultGridResult;
import org.durcframework.core.GridResult;
import org.durcframework.core.MessageResult;
import org.durcframework.core.controller.CrudController;
import org.durcframework.core.expression.Expression;
import org.durcframework.core.expression.ExpressionQuery;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.nashuju.web.entity.sys.SysClasstype;
import com.nashuju.web.entity.sys.SysClasstypeSch;
import com.nashuju.web.service.sys.SysClasstypeService;

@Controller
public class SysClasstypeController extends CrudController<SysClasstype, SysClasstypeService> {

    @RequestMapping("/addCSysClasstype.do")
    public @ResponseBody MessageResult addCSysClasstype(SysClasstype entity) {
        return this.save(entity);
    }

    @RequestMapping("/listCSysClasstype.do")
    public @ResponseBody GridResult listCSysClasstype(SysClasstypeSch searchEntity) {
        return this.query(searchEntity);
    }

    @RequestMapping("/updateCSysClasstype.do")
    public @ResponseBody MessageResult updateCSysClasstype(SysClasstype entity) {
        return this.update(entity);
    }

    @RequestMapping("/delCSysClasstype.do")
    public @ResponseBody MessageResult delCSysClasstype(SysClasstype entity) {
        return this.delete(entity);
    }

    @RequestMapping("/getSysClasstypeById.do")
    public @ResponseBody SysClasstype getSysClasstypeById(SysClasstype entity) {
        return this.getService().get(entity.getId());
    }

    @RequestMapping("/listCSysClasstypeAll.do")
    public @ResponseBody Object listCSysClasstypeAll(SysClasstype entity) {
        ExpressionQuery query = ExpressionQuery.buildQueryAll();
        List<Expression> expressions = new ArrayList<Expression>();
        query.addAll(expressions);
        // query.addSort("id", "asc");
        DefaultGridResult resultGrid = (DefaultGridResult) this.queryAll(query);
        @SuppressWarnings("unchecked")
        List<SysClasstype> rows = (List<SysClasstype>) resultGrid.getRows();
        return rows;
    }

}
